//
//  TravelModel.m
//  ToWhere
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "TravelModel.h"
#import "TraveAreaModel.h"

@implementation TravelModel

-(void)dealloc
{
    [_array release];
    [_category release];
    
    [super dealloc];
}

-(instancetype)initWithNSDictionary:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        self.array = [NSMutableArray array];
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+(TravelModel *)travelModelinitWithNSDictionary:(NSDictionary *)dic
{
    
    TravelModel *model = [[TravelModel alloc]initWithNSDictionary:dic];
    
    return [model autorelease];
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqualToString:@"destinations"]) {
        
        NSArray *arrayT = value;
        
        for (NSDictionary *dic in arrayT) {
            
            TraveAreaModel *model = [TraveAreaModel travelAreaModelinitWithNSDictionary: dic];
            
            [self.array addObject:model];
        }
    }
   
}

@end
